<!--
 Copyright (c) HashiCorp, Inc.
 SPDX-License-Identifier: MPL-2.0
-->

<!-- A minimal HTML page for simple testing via a UI without vault. -->
<html>
<body>
Role:<br>
<input id="role" type="text" value="test"/><br>
<button id="login">Login</button>

<script>
document.getElementById("login").addEventListener("click", doLogin);

function doLogin() {
	role = document.getElementById("role").value;

	fetch(`${window.location.origin}/v1/auth/jwt/oidc/auth_url`, {
		method: "POST",
		body: JSON.stringify({
			role: role,
			redirect_uri: `${window.location.origin}/v1/auth/jwt/oidc/callback`
		})
	}).then(function(response) {
		return response.json();
	}).then(function(myJSON) {
		oidcAuth(myJSON.data.auth_url);
	});
}

function oidcAuth(url) {
	console.log(url);
	url = url.replace("vaultserver", window.location.origin);
	console.log(url);
	location.replace(url);
}

</script>

</body>
</html>
